package com.bjpowernode.springboot.controller;

import com.bjpowernode.springboot.model.Student;
import com.bjpowernode.springboot.service.StudentService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class StudentController {

    @DubboReference(interfaceClass = StudentService.class,version="1.0.0",check = false)
    private StudentService studentService;

    @RequestMapping(value = "/student/detail/{id}")
    public String studentDetail(Model model,@PathVariable("id") Integer id){

        Student student=studentService.queryStudentById(id);
        model.addAttribute("student",student);

        return "studentDetail";
    }

    @GetMapping(value="/student/all/count")
    public @ResponseBody Object StudentCount(){

        Integer studentCount=studentService.queryStudentCount();
        return "学生总人数为："+studentCount;
    }

}
